package com.git_taoxian.test6;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;

public class Test {
    @org.junit.Test
    public void parseMethod() {
//        获取当前类的对象
        Class clz = TestDemo.class;
//        获取当前的所有方法的对象
        Method[] methods = clz.getDeclaredMethods();
//        循环遍历所有的方法 找出被注解的方法
        for (Method method : methods) {
            //解析TestDemo类上的注解
            if (method.isAnnotationPresent(MyTest.class)) {
//                获取注解
                MyTest myTest = method.getDeclaredAnnotation(MyTest.class);
//                获取注解的属性值并打印
                System.out.println(myTest.name());
                System.out.println(myTest.age());
                System.out.println(Arrays.toString(myTest.score()));
            }
        }
    }
}

class TestDemo {
    @MyTest(name = "张三", age = 18, score = {25.12, 23.56, 17.99})
    public void testDemo() {

    }
}